package com.maiji.cloud.cfgbeans;

import com.netflix.loadbalancer.*;
import org.springframework.context.annotation.Bean;

public class RibbonAppLoginConfig {

    @Bean  // 自定义负载策略
    public IRule myRule()	{
        // 根据服务是否死掉或者服务处于高并发来分配权重
//        return new AvailabilityFilteringRule();
        // 轮询负载
        return new RoundRobinRule();
    }

    /**
     * 自定义服务列表
     String listOfServers = "http://localhost:8031";

     @Bean
     public ServerList<Server> ribbonServerList() {
     List<Server> list = Lists.newArrayList();
     if (!Strings.isNullOrEmpty(listOfServers)) {
     for (String s: listOfServers.split(",")) {
     list.add(new Server(s.trim()));
     }
     }
     Server[] serverList = new Server[list.size()];
     list.toArray(serverList);
     return new StaticServerList<Server>(serverList);
     }*/

}
